import { getStorage, setStorage } from '@/utils/cache/storage'
import { defineStore } from 'pinia'

interface InfoState {
  filePath: string
  name: string
}

export const platformStore = defineStore('platform', {
  state: (): InfoState => ({
    filePath: getStorage('filePath') ?? '',
    name: getStorage('platform-name') ?? ''
  }),
  actions: {
    setPlatform(info: InfoState) {
      this.filePath = info.filePath
      setStorage('filePath', info.filePath)

      this.name = info.name
      setStorage('platform-name', info.name)
    }
  }
})
